#include <cstdlib>
#include <iostream>
#include "grafo.h"
#include "busqueda_tabu.h"

using namespace std;

class Grafo leerInput(istream&, vector<int> &clique);
void escribirOutput(ostream&, const vector<uint>&);

Grafo leerInput(istream& is, vector<int> &clique) {
	uint n, m;
	is >> n >> m;

	Grafo grafo(n);
	for (int k=0; k < m; k++) {
		uint i, j;
		is >> i >> j;
		grafo.agregarArista(i,j);
	}
	
	is >> n >> m;
	
	for (int k=0; k < n; k++) {
		int i;
		is >> i;
		clique.push_back(i);
	}
	
	return grafo;
}

ostream& operator<<(ostream &os, vector<uint> &solucion) {
	for(vector<uint>::iterator it = solucion.begin(); it != solucion.end(); it++)
		os << (*it) << " ";
	os << endl;
	return os;
}


int main() {
	vector<int> clique;
	Grafo grafo = leerInput(cin, clique);

	//~ CliqueMaximaFronteraExacto iniciar(grafo);
	CliqueMaximaFronteraTabu iniciar(grafo);

	vector<uint> solucion = iniciar.resolver(clique);

	cout << solucion;

	return 0;
}
